import * as THREE from 'three';
const model = new THREE.Group();
const loader = new THREE.FileLoader();
var buildGroup = new THREE.Group(); 
loader.setResponseType('json')
loader.load(
	'/黄浦江.json',(data)=>{
    data.features.forEach(build => {
      buildGroup.add(ShapeMesh(build.geometry.coordinates)) 
    });
    model.add(buildGroup)
    console.log('buildGroup',buildGroup);
  })
const ShapeMesh = function(pointsArr){
  var vector2Arr = []
  pointsArr[0].forEach(elem=>{
    vector2Arr.push(new THREE.Vector2(elem[0],elem[1]))
  })
  const heartShape = new THREE.Shape(vector2Arr);
  const geometry = new THREE.ShapeGeometry( heartShape );
  const material =  new THREE.MeshLambertMaterial({
    color:0x0099ff
  })
  const mesh = new THREE.Mesh( geometry, material);
  return mesh
}

export {model};